package com.dk.post.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dk.post.dao.PostDao;
import com.dk.post.dto.PostDTO;
import com.dk.post.entity.PostEntity;
import com.dk.post.service.PostService;
import com.ts.common.core.service.impl.CrudServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 帖子表
 *
 * @author toString toString@qq.com
 * @since 1.0.0 2023-12-05
 */
@Service
public class PostServiceImpl extends CrudServiceImpl<PostDao, PostEntity, PostDTO> implements PostService {

    @Override
    public QueryWrapper<PostEntity> getWrapper(Map<String, Object> params){

        QueryWrapper<PostEntity> wrapper = new QueryWrapper<>();
        //做一个非空判断，防止空指针异常，因为传过来的params为null
        if (params != null){
            String id = (String)params.get("id");
            wrapper.eq(StringUtils.isNotBlank(id), "id", id);
        }
        return wrapper;
    }


}